home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / polysDisplaySetup.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  25.6 KB  |  789 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  April 22, 1997
  22. //  Author:         tbaudel
  23. //
  24. //  Description:
  25. //         Display -> Custom Polygon Setup item
  26. //
  27. //  Input Arguments:
  28. //      int    if 1 show option box
  29. //            if 0 perform command with current values
  30. //             if 2 returns the default settings as a command string
  31. //  Return Value:
  32. //      none
  33. //
  34.  
  35. proc setOptionVars (int $forceFactorySettings)
  36. {
  37.     // Objects Afftected
  38.     //
  39.     if ($forceFactorySettings || !`optionVar -exists displayPolyObjsAffected`)
  40.         optionVar -intValue displayPolyObjsAffected 0;
  41.     
  42.     // Vertices Display
  43.     if ($forceFactorySettings || !`optionVar -exists displayPolyVtxDisp`) {
  44.         optionVar -clearArray displayPolyVtxDisp;
  45.         optionVar -intValue displayPolyVtxDisp 0
  46.              -intValueAppend displayPolyVtxDisp 0;
  47.     }
  48.     
  49.     // Vertices Backculling
  50.     if ($forceFactorySettings || !`optionVar -exists displayPolyVtxBackCull`) {
  51.         optionVar -clearArray displayPolyVtxBackCull;
  52.         optionVar -intValue displayPolyVtxBackCull 1
  53.             -intValueAppend displayPolyVtxBackCull 1;
  54.     }
  55.  
  56.     // Vertex Normals 
  57.     //
  58.     if ($forceFactorySettings || !`optionVar -exists displayPolyVertexNormals`) {
  59.         optionVar -clearArray displayPolyVertexNormals;
  60.         optionVar -intValue displayPolyVertexNormals 0
  61.             -intValueAppend displayPolyVertexNormals 0;
  62.     }
  63.                 
  64.     // Edge Display
  65.     if ($forceFactorySettings || !`optionVar -exists displayPolyEdgeDisp`) {
  66.         optionVar -clearArray displayPolyEdgeDisp;
  67.         optionVar -intValue displayPolyEdgeDisp 0
  68.             -intValueAppend displayPolyEdgeDisp 0;
  69.     }
  70.  
  71.     // Border Edge Size
  72.     //
  73.     if ($forceFactorySettings || !`optionVar -exists displayPolyBorderEdgeSize`) {
  74.         optionVar -clearArray displayPolyBorderEdgeSize;
  75.         optionVar -floatValue displayPolyBorderEdgeSize 3.0
  76.             -floatValueAppend displayPolyBorderEdgeSize 3.0;
  77.     }
  78.     
  79.     // Border Edge Highlighting
  80.     //
  81.     if ($forceFactorySettings || !`optionVar -exists displayPolyBorderEdgeHilite`) {
  82.         optionVar -clearArray displayPolyBorderEdgeHilite;
  83.         optionVar -intValue displayPolyBorderEdgeHilite 0
  84.             -intValueAppend displayPolyBorderEdgeHilite 0;
  85.     }
  86.     
  87.     // Border Map Highlighting
  88.     //
  89.     if ($forceFactorySettings || !`optionVar -exists displayPolyBorderMapHilite`) {
  90.         optionVar -clearArray displayPolyBorderMapHilite;
  91.         optionVar -intValue displayPolyBorderMapHilite 0
  92.             -intValueAppend displayPolyBorderMapHilite 0;
  93.     }
  94.  
  95.     // UV and Display UV Topology Display 
  96.     if ($forceFactorySettings || !`optionVar -exists displayPolyUV`) {
  97.         optionVar -clearArray displayPolyUV;
  98.         optionVar -intValue displayPolyUV 0
  99.             -intValueAppend displayPolyUV 0;
  100.     }    
  101.     if ($forceFactorySettings || !`optionVar -exists displayPolyUVTopology`) {
  102.         optionVar -clearArray displayPolyUVTopology;
  103.         optionVar -intValue displayPolyUVTopology 0
  104.             -intValueAppend displayPolyUVTopology 0;
  105.     }    
  106.  
  107.     // Normal Size
  108.     //
  109.     if ($forceFactorySettings || !`optionVar -exists displayPolyNormalSize`) {
  110.         optionVar -clearArray displayPolyNormalSize;
  111.         optionVar -floatValue displayPolyNormalSize 0.4
  112.             -floatValueAppend displayPolyNormalSize 0.4;
  113.     }
  114.     
  115.     // Facets Display
  116.     //
  117.     if ($forceFactorySettings || !`optionVar -exists displayPolyFacetCentreDisp`) {
  118.         optionVar -clearArray displayPolyFacetCentreDisp;
  119.         optionVar -intValue displayPolyFacetCentreDisp 0
  120.             -intValueAppend displayPolyFacetCentreDisp 0;
  121.     }
  122.  
  123.     if ($forceFactorySettings || !`optionVar -exists displayPolyFacetNormalDisp`) {
  124.         optionVar -clearArray displayPolyFacetNormalDisp;
  125.         optionVar -intValue displayPolyFacetNormalDisp 0
  126.             -intValueAppend displayPolyFacetNormalDisp 0;
  127.     }
  128.  
  129.     if ($forceFactorySettings || !`optionVar -exists displayPolyFacetTrngleDisp`) {
  130.         optionVar -clearArray displayPolyFacetTrngleDisp;
  131.         optionVar -intValue displayPolyFacetTrngleDisp 0
  132.             -intValueAppend displayPolyFacetTrngleDisp 0;
  133.     }
  134.  
  135.     if ($forceFactorySettings || !`optionVar -exists displayPolyFacetWarpDisp`) {
  136.         optionVar -clearArray displayPolyFacetWarpDisp;
  137.         optionVar -intValue displayPolyFacetWarpDisp 0
  138.             -intValueAppend displayPolyFacetWarpDisp 0;
  139.     }
  140.  
  141.     if ($forceFactorySettings || !`optionVar -exists displayPolyNumVertex`) {
  142.         optionVar -clearArray displayPolyNumVertex;
  143.         optionVar -intValue displayPolyNumVertex 0
  144.             -intValueAppend displayPolyNumVertex 0;
  145.     }
  146.     if ($forceFactorySettings || !`optionVar -exists displayPolyNumEdge`) {
  147.         optionVar -clearArray displayPolyNumEdge;
  148.         optionVar -intValue displayPolyNumEdge 0
  149.             -intValueAppend displayPolyNumEdge 0;
  150.     }
  151.     if ($forceFactorySettings || !`optionVar -exists displayPolyNumFacet`) {
  152.         optionVar -clearArray displayPolyNumFacet;
  153.         optionVar -intValue displayPolyNumFacet 0
  154.             -intValueAppend displayPolyNumFacet 0;
  155.     }
  156.     if ($forceFactorySettings || !`optionVar -exists displayPolyNumUv`) {
  157.         optionVar -clearArray displayPolyNumUv;
  158.         optionVar -intValue displayPolyNumUv 0
  159.             -intValueAppend displayPolyNumUv 0;
  160.     }
  161.  
  162.     // Backface Culling
  163.     //
  164.     if ($forceFactorySettings || !`optionVar -exists displayPolyBackFaceCull`) {
  165.         optionVar -clearArray displayPolyBackFaceCull;
  166.         optionVar -intValue displayPolyBackFaceCull 0
  167.             -intValueAppend displayPolyBackFaceCull 0;
  168.     }
  169.  
  170.     // Colors
  171.     //
  172.     if ($forceFactorySettings || !`optionVar -exists colorShadedDisplay`) {
  173.         optionVar -clearArray colorShadedDisplay;
  174.         optionVar -intValue colorShadedDisplay 0
  175.             -intValueAppend colorShadedDisplay 0;        
  176.     }
  177.  
  178.     if ($forceFactorySettings || !`optionVar -exists colorMaterialChannel`) {
  179.         optionVar -clearArray colorMaterialChannel;
  180.         optionVar -intValue colorMaterialChannel 3 // diffuse
  181.             -intValueAppend colorMaterialChannel 3;        
  182.     }
  183. }
  184.  
  185. global proc polysDisplayUpdateCulling (string $parent)
  186. {
  187.     setParent $parent;
  188.  
  189.     int $backfaceCulling = `optionMenuGrp -query -select backfaceCullPopup`;
  190.     checkBoxGrp -edit -enable3 ($backfaceCulling != 1) polyVerticesDisplayCheck;    
  191. }
  192.  
  193. global proc polysDisplaySetupSetup (string $parent, int $forceFactorySettings)
  194. {
  195.     // Retrieve the option settings
  196.     //
  197.     setOptionVars ($forceFactorySettings);
  198.     setParent $parent;
  199.  
  200.     int $o = `optionVar -q displayPolyObjsAffected`;
  201.  
  202.     radioButtonGrp -e -sl ($o + 1) polyObjsAffectedRadio;
  203.  
  204.     int $vals[3]; int $vals2[3]; int $vals3[3]; int $vals4[3]; int $val;
  205.     float $fvals[3]; float $fvals2[3];
  206.     string $sval;
  207.     
  208.     $vals=`optionVar -q displayPolyVtxDisp`;
  209.     checkBoxGrp -e -v1 $vals[$o] polyVerticesDisplayCheck;
  210.  
  211.     $vals=`optionVar -q displayPolyVtxBackCull`;
  212.     checkBoxGrp -e -v3 $vals[$o] polyVerticesDisplayCheck;    
  213.     
  214.     $vals=`optionVar -q displayPolyVertexNormals`;
  215.     checkBoxGrp -e -v2 $vals[$o] polyVerticesDisplayCheck;    
  216.  
  217.     $vals=`optionVar -q displayPolyEdgeDisp`;
  218.     radioButtonGrp -e -sl ($vals[$o] + 1) polyEdgeDisplayRadio;
  219.  
  220.     $fvals=`optionVar -q displayPolyBorderEdgeSize`;
  221.     floatSliderGrp -e -value $fvals[$o] borderEdgeSizeSlider;
  222.     
  223.     // Border Edge Highlighting
  224.     //
  225.     $vals=`optionVar -q displayPolyBorderEdgeHilite`;
  226.     $vals2=`optionVar -q displayPolyBorderMapHilite` ;
  227.     checkBoxGrp -e -v1 $vals[$o] -v2 $vals2[$o] borderEdgeHiliteDisplayCheck;
  228.  
  229.     // UV Topology Display - BK
  230.     $vals=`optionVar -q displayPolyUV`;
  231.     $vals2 =`optionVar -q displayPolyUVTopology`;
  232.     checkBoxGrp -e -v1 $vals[$o] -v2 $vals2[$o] polyUVDisplayCheck;
  233.     
  234.     // NormalSize
  235.     //
  236.     $fvals=`optionVar -q displayPolyNormalSize`;
  237.     floatSliderGrp -e -value $fvals[$o] normalSizeSlider;
  238.     
  239.     // Facets Display
  240.     //
  241.     $vals= `optionVar -q displayPolyFacetCentreDisp` ;
  242.     $vals2=`optionVar -q displayPolyFacetNormalDisp`;
  243.     $vals3=`optionVar -q displayPolyFacetTrngleDisp`;
  244.     $vals4=`optionVar -q displayPolyFacetWarpDisp`;
  245.     checkBoxGrp -e -v1 $vals[$o] -v2 $vals2[$o] -v3 $vals3[$o] -v4 $vals4[$o] polyFacetDisplayCheck;
  246.  
  247.     // Item numbers Display
  248.     //
  249.     $vals= `optionVar -q displayPolyNumVertex` ;
  250.     $vals2=`optionVar -q displayPolyNumEdge`;
  251.     $vals3=`optionVar -q displayPolyNumFacet`;
  252.     $vals4=`optionVar -q displayPolyNumUv`;
  253.     checkBoxGrp -e -v1 $vals[$o] -v2 $vals2[$o] -v3 $vals3[$o] -v4 $vals4[$o] polyItemDisplayCheck;
  254.  
  255.     // Backface Culling
  256.     //
  257.     $vals=`optionVar -q displayPolyBackFaceCull`;
  258.     optionMenuGrp -e -sl ($vals[$o] + 1) backfaceCullPopup;
  259.  
  260.     // Colors
  261.     $vals = `optionVar -q colorShadedDisplay`;
  262.     checkBoxGrp  -e -v1 $vals[$o] colorShadedDisplayCheck;
  263.  
  264.     $vals = `optionVar -q colorMaterialChannel`;
  265.     optionMenuGrp -e -sl ($vals[$o]+1) colorMaterialPopup;
  266.  
  267.     // Update the culling settings
  268.     //
  269.     polysDisplayUpdateCulling ($parent);
  270. }
  271.  
  272. global proc polysDisplaySetupCallback (string $parent, int $doIt)
  273. {
  274.      setParent $parent;
  275.  
  276.     // Set the optionVar's from the control values, and then perform the command
  277.     //
  278.     int $o = `radioButtonGrp -q -sl polyObjsAffectedRadio`;
  279.     if ($o < 1) $o=1; $o--;
  280.     optionVar -intValue displayPolyObjsAffected $o;
  281.  
  282.     int $vals[2]; float $fvals[2]; int $val;
  283.  
  284.     $vals=`optionVar -q displayPolyVtxDisp`;
  285.     $vals[$o]=`checkBoxGrp -q -v1 polyVerticesDisplayCheck`;
  286.     optionVar -clearArray displayPolyVtxDisp;
  287.     optionVar -intValue displayPolyVtxDisp $vals[0]
  288.         -intValueAppend displayPolyVtxDisp $vals[1];
  289.  
  290.     $vals=`optionVar -q displayPolyVtxBackCull`;
  291.     $vals[$o]=`checkBoxGrp -q -v3 polyVerticesDisplayCheck`;
  292.     optionVar -clearArray displayPolyVtxBackCull;
  293.     optionVar -intValue displayPolyVtxBackCull $vals[0]
  294.         -intValueAppend displayPolyVtxBackCull $vals[1];
  295.     
  296.     $vals=`optionVar -q displayPolyVertexNormals`;
  297.     $vals[$o]=`checkBoxGrp -q -v2 polyVerticesDisplayCheck`;
  298.     optionVar -clearArray displayPolyVertexNormals;
  299.     optionVar -intValue displayPolyVertexNormals $vals[0]
  300.         -intValueAppend displayPolyVertexNormals $vals[1];
  301.     
  302.     $vals=`optionVar -q displayPolyEdgeDisp`;
  303.     $vals[$o]=`radioButtonGrp -q -sl polyEdgeDisplayRadio` - 1;
  304.     optionVar -clearArray displayPolyEdgeDisp;
  305.     optionVar -intValue displayPolyEdgeDisp $vals[0]
  306.         -intValueAppend displayPolyEdgeDisp $vals[1];
  307.     
  308.     $fvals=`optionVar -q displayPolyBorderEdgeSize`;
  309.     $fvals[$o]=`floatSliderGrp -q -value borderEdgeSizeSlider`;
  310.     optionVar -clearArray displayPolyBorderEdgeSize;
  311.     optionVar -floatValue displayPolyBorderEdgeSize $fvals[0]
  312.         -floatValueAppend displayPolyBorderEdgeSize $fvals[1];
  313.                 
  314.     $vals=`optionVar -q displayPolyBorderEdgeHilite`;
  315.     $vals[$o]=`checkBoxGrp -q -v1 borderEdgeHiliteDisplayCheck`;
  316.     optionVar -clearArray displayPolyBorderEdgeHilite;
  317.     optionVar -intValue displayPolyBorderEdgeHilite $vals[0]
  318.         -intValueAppend displayPolyBorderEdgeHilite $vals[1];
  319.         
  320.     $vals=`optionVar -q displayPolyBorderMapHilite`;
  321.     $vals[$o]=`checkBoxGrp -q -v2 borderEdgeHiliteDisplayCheck`;
  322.     optionVar -clearArray displayPolyBorderMapHilite;
  323.     optionVar -intValue displayPolyBorderMapHilite $vals[0]
  324.         -intValueAppend displayPolyBorderMapHilite $vals[1];
  325.                 
  326.     $vals=`optionVar -q displayPolyFacetCentreDisp`;
  327.     $vals[$o]=`checkBoxGrp -q -v1 polyFacetDisplayCheck`;
  328.     optionVar -clearArray displayPolyFacetCentreDisp;
  329.     optionVar -intValue displayPolyFacetCentreDisp $vals[0]
  330.         -intValueAppend displayPolyFacetCentreDisp $vals[1];
  331.                 
  332.     $vals=`optionVar -q displayPolyFacetNormalDisp`;
  333.     $vals[$o]=`checkBoxGrp -q -v2 polyFacetDisplayCheck`;
  334.     optionVar -clearArray displayPolyFacetNormalDisp;
  335.     optionVar -intValue displayPolyFacetNormalDisp $vals[0]
  336.         -intValueAppend displayPolyFacetNormalDisp $vals[1];
  337.  
  338.     $vals=`optionVar -q displayPolyFacetTrngleDisp`;
  339.     $vals[$o]=`checkBoxGrp -q -v3 polyFacetDisplayCheck`;
  340.     optionVar -clearArray displayPolyFacetTrngleDisp;
  341.     optionVar -intValue displayPolyFacetTrngleDisp $vals[0]
  342.         -intValueAppend displayPolyFacetTrngleDisp $vals[1];
  343.  
  344.     $vals=`optionVar -q displayPolyFacetWarpDisp`;
  345.     $vals[$o]=`checkBoxGrp -q -v4 polyFacetDisplayCheck`;
  346.     optionVar -clearArray displayPolyFacetWarpDisp;
  347.     optionVar -intValue displayPolyFacetWarpDisp $vals[0]
  348.         -intValueAppend displayPolyFacetWarpDisp $vals[1];
  349.  
  350.     $vals=`optionVar -q displayPolyNumVertex`;
  351.     $vals[$o]=`checkBoxGrp -q -v1 polyItemDisplayCheck`;
  352.     optionVar -clearArray displayPolyNumVertex;
  353.     optionVar -intValue displayPolyNumVertex $vals[0]
  354.         -intValueAppend displayPolyNumVertex $vals[1];
  355.     $vals=`optionVar -q displayPolyNumEdge`;
  356.     $vals[$o]=`checkBoxGrp -q -v2 polyItemDisplayCheck`;
  357.     optionVar -clearArray displayPolyNumEdge;
  358.     optionVar -intValue displayPolyNumEdge $vals[0]
  359.         -intValueAppend displayPolyNumEdge $vals[1];
  360.     $vals=`optionVar -q displayPolyNumFacet`;
  361.     $vals[$o]=`checkBoxGrp -q -v3 polyItemDisplayCheck`;
  362.     optionVar -clearArray displayPolyNumFacet;
  363.     optionVar -intValue displayPolyNumFacet $vals[0]
  364.         -intValueAppend displayPolyNumFacet $vals[1];
  365.     $vals=`optionVar -q displayPolyNumUv`;
  366.     $vals[$o]=`checkBoxGrp -q -v4 polyItemDisplayCheck`;
  367.     optionVar -clearArray displayPolyNumUv;
  368.     optionVar -intValue displayPolyNumUv $vals[0]
  369.         -intValueAppend displayPolyNumUv $vals[1];
  370.     
  371.     $fvals=`optionVar -q displayPolyNormalSize`;
  372.     $fvals[$o]=`floatSliderGrp -q -value normalSizeSlider`;
  373.     optionVar -clearArray displayPolyNormalSize;
  374.     optionVar -floatValue displayPolyNormalSize $fvals[0]
  375.         -floatValueAppend displayPolyNormalSize $fvals[1];
  376.  
  377.     // UV and UV Topology 
  378.     $vals=`optionVar -q displayPolyUV`;
  379.     $vals[$o]=`checkBoxGrp -q -v1 polyUVDisplayCheck`;
  380.     optionVar -clearArray displayPolyUV;
  381.     optionVar -intValue displayPolyUV $vals[0]
  382.         -intValueAppend displayPolyUV $vals[1];
  383.     //
  384.     $vals=`optionVar -q displayPolyUVTopology`;
  385.     $vals[$o]=`checkBoxGrp -q -v2 polyUVDisplayCheck`;
  386.     optionVar -clearArray displayPolyUVTopology;
  387.     optionVar -intValue displayPolyUVTopology $vals[0]
  388.         -intValueAppend displayPolyUVTopology $vals[1];
  389.  
  390.     // Colors
  391.     $vals = `optionVar -q colorShadedDisplay`;
  392.     $vals[$o] = `checkBoxGrp -q -v1 colorShadedDisplayCheck`;
  393.     optionVar -clearArray colorShadedDisplay;
  394.     optionVar -intValue colorShadedDisplay $vals[0]
  395.         -intValueAppend colorShadedDisplay $vals[1];
  396.  
  397.     $vals = `optionVar -q colorMaterialChannel`;
  398.     $vals[$o] = `optionMenuGrp -q -sl colorMaterialPopup` -1;
  399.     optionVar -clearArray colorMaterialChannel;
  400.     optionVar -intValue colorMaterialChannel $vals[0]
  401.         -intValueAppend colorMaterialChannel $vals[1];
  402.     
  403.  
  404.     // Culling
  405.     $vals=`optionVar -q displayPolyBackFaceCull`;
  406.     $vals[$o]=`optionMenuGrp -q -sl backfaceCullPopup` - 1;
  407.     optionVar -clearArray displayPolyBackFaceCull;
  408.     optionVar -intValue displayPolyBackFaceCull $vals[0]
  409.         -intValueAppend displayPolyBackFaceCull $vals[1];
  410.  
  411.     if ($doIt) polysDisplaySetup 0;
  412. }
  413.  
  414. //
  415. //  Procedure Name:
  416. //      polysDisplaySetupOptions
  417. //
  418. //  Description:
  419. //        Construct the option box UI.  Involves accessing the standard option
  420. //        box and customizing the UI accordingly.
  421. //
  422. //  Input Arguments:
  423. //      None.
  424. //
  425. //  Return Value:
  426. //      None.
  427. //
  428. proc polysDisplaySetupOptions()
  429. {
  430.     //    Name of the command for this option box.
  431.     //
  432.     string $commandName = "polysDisplaySetup";
  433.  
  434.     //    Build the option box actions.
  435.     //
  436.     string $callback = ($commandName + "Callback");
  437.     string $setup = ($commandName + "Setup");
  438.  
  439.     //    STEP 1:  Get the option box.
  440.     //    ============================
  441.     //
  442.     //    The value returned is the name of the layout to be used as
  443.     //    the parent for the option box UI.
  444.     //
  445.     string $layout = getOptionBox();
  446.     setParent $layout;
  447.     
  448.     //    STEP 2:  Pass the command name to the option box.
  449.     //    =================================================
  450.     //
  451.     //    Any default option box behaviour based on the command name is set 
  452.     //    up with this call.  For example, updating the 'Help' menu item with
  453.     //    the name of the command.
  454.     //
  455.     setOptionBoxTitle("Custom Polygon Display Options");
  456.     setOptionBoxCommandName($commandName);
  457.     
  458.     //    STEP 3:  Activate the default UI template.
  459.     //    ==========================================
  460.     //
  461.     //    Activate the default UI template so that the layout of this 
  462.     //    option box is consistent with the layout of the rest of the 
  463.     //    application.
  464.     //
  465.     setUITemplate -pushTemplate DefaultTemplate;
  466.  
  467.     //    STEP 4: Create option box contents.
  468.     //    ===================================
  469.     //    
  470.     //    This, of course, will vary from option box to option box.    
  471.     
  472.     //    Turn on the wait cursor.
  473.     //
  474.     waitCursor -state 1;
  475.  
  476.     tabLayout -tabsVisible 0 -scrollable 1;
  477.     
  478.     string $parent = `columnLayout -adjustableColumn 1`;
  479.     
  480.     string $tmp = ("setParent " + $layout + "; "
  481.                 + "int $o=(`radioButtonGrp -q -sl polyObjsAffectedRadio` - 1); "
  482.                 + "if ($o >= 0) { optionVar -intValue displayPolyObjsAffected $o ; "
  483.                 + $setup + " " + $layout + " false; }");
  484.  
  485.     radioButtonGrp -numberOfRadioButtons 2
  486.             -label "Objects Affected" 
  487.                 -l1 "Selected" -l2 "All" 
  488.                 -cc $tmp
  489.                 polyObjsAffectedRadio;
  490.     separator;
  491.     
  492.     // vertices drawing style
  493.     checkBoxGrp -numberOfCheckBoxes 3
  494.             -label "Vertices" 
  495.             -l1 "Display"  
  496.             -l2 "Normals" 
  497.             -l3 "Backculling" 
  498.             polyVerticesDisplayCheck;
  499.     
  500.     separator;
  501.     radioButtonGrp -numberOfRadioButtons 3
  502.             -label "Edges" 
  503.             -l1 "Standard" 
  504.             -l2 "Soft/Hard" 
  505.             -l3 "Only Hard"
  506.             polyEdgeDisplayRadio;
  507.             
  508.     checkBoxGrp -numberOfCheckBoxes 2
  509.             -label "Highlight" 
  510.             -l1 "Border Edges" 
  511.             -l2 "Texture Borders" 
  512.             borderEdgeHiliteDisplayCheck;
  513.     
  514.     floatSliderGrp -label "Border Width"
  515.             -min 1 -max 10 borderEdgeSizeSlider;
  516.  
  517.     separator;
  518.  
  519.     checkBoxGrp -numberOfCheckBoxes 4
  520.             -label "Face" -l1 "Centers" -l2 "Normals" -l3    "Triangles" -l4 "Non-planar"
  521.             polyFacetDisplayCheck;
  522.             
  523.     separator;
  524.     
  525.     checkBoxGrp -numberOfCheckBoxes 4
  526.         -label "Show Item Numbers"
  527.         -la4 "Vertices" "Edges" "Face" "UVs"
  528.         polyItemDisplayCheck;
  529.  
  530.     floatSliderGrp -label "Normals Size" -min 0.02 -max 10 normalSizeSlider;
  531.  
  532.     // UV and UV topology display - BK
  533.     checkBoxGrp -numberOfCheckBoxes 2
  534.         -label "Texture Coordinates" 
  535.         -la2 "UV" "UV Topology" 
  536.         polyUVDisplayCheck;
  537.  
  538.     separator;
  539.  
  540.     // Colors
  541.     checkBoxGrp -numberOfCheckBoxes 1
  542.         -label "Color"
  543.         -l1 "Color in Shaded Display"
  544.         colorShadedDisplayCheck;
  545.  
  546.     optionMenuGrp -l "Color Material Channel" colorMaterialPopup;
  547.     {
  548.         menuItem -l "None" materialNoneMenuItem;
  549.         menuItem -l "Ambient" materialAmbientMenuItem;
  550.         menuItem -l "Ambient+Diffuse" materialAmbDiffMenuItem;
  551.         menuItem -l "Diffuse" materialDiffuseMenuItem;
  552.         menuItem -l "Specular" materialSpecularMenuItem;
  553.         menuItem -l "Emission" materialEmissionMenuItem;
  554.         setParent -m ..;
  555.     }
  556.  
  557.     separator;
  558.  
  559.     optionMenuGrp  -l "Backface Culling" -changeCommand ("polysDisplayUpdateCulling " + $parent) backfaceCullPopup;
  560.         menuItem -l "Off" backfaceOffMenuItem;
  561.         menuItem -l "On" backfaceOnMenuItem;
  562.         menuItem -l "Keep Wire" backfaceWireMenuItem;
  563.         menuItem -l "Keep Hard Edges" backfaceHardEdgeMenuItem;
  564.         setParent -m ..;
  565.     
  566.         setParent ..;
  567.     setParent ..;
  568.     
  569.     //    Turn off the wait cursor.
  570.     //
  571.     waitCursor -state 0;
  572.     
  573.     //    Step 5: Deactivate the default UI template.
  574.     //    ===========================================
  575.     //
  576.     setUITemplate -popTemplate;
  577.  
  578.     //    Step 6: Customize the buttons.  
  579.     //    ==============================
  580.     //
  581.     //    Provide more descriptive labels for the buttons.  This is not 
  582.     //    necessary, but in some cases, for example, a button labelled 
  583.     //    'Create' may be more meaningful to the user than one labelled
  584.     //    'Apply'.
  585.     //
  586.     //    Disable those buttons that are not applicable to the option box.
  587.     //
  588.     //    Attach actions to those buttons that are applicable to the option
  589.     //    box.  Note that the 'Close' button has a default action attached 
  590.     //    to it that will hide the window.  If a a custom action is
  591.     //    attached to the 'Close' button then be sure to call the 'hide the
  592.     //    option box' procedure within the custom action so that the option
  593.     //    box is hidden properly.
  594.  
  595.     //    'Apply' button.
  596.     //
  597.     string $applyBtn = getOptionBoxApplyBtn();
  598.     button -edit
  599.         -command ($callback + " " + $parent + " " + 1)
  600.         $applyBtn;
  601.  
  602.     //    'Save' button.
  603.     //
  604.     string $saveBtn = getOptionBoxSaveBtn();
  605.     button -edit 
  606.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  607.         $saveBtn;
  608.  
  609.     //    'Reset' button.
  610.     //
  611.     string $resetBtn = getOptionBoxResetBtn();
  612.     button -edit 
  613.         -command ($setup + " " + $parent + " " + 1)
  614.         $resetBtn;
  615.  
  616.     //    Step 7: Set the option box title.
  617.     //    =================================
  618.     //
  619.     setOptionBoxTitle("Custom Polygon Display Options");
  620.  
  621.     //    Step 8: Customize the 'Help' menu item text.
  622.     //    ============================================
  623.     //
  624.     setOptionBoxHelpTag( "CustomPolygonDisplay" );
  625.  
  626.     //    Step 9: Set the current values of the option box.
  627.     //    =================================================
  628.     //
  629.     eval (($setup + " " + $parent + " " + 0));    
  630.     
  631.     //    Step 10: Show the option box.
  632.     //    =============================
  633.     //
  634.     showOptionBox();
  635. }
  636.  
  637.  
  638. //
  639. //  Procedure Name:
  640. //      assembleCmd
  641. //
  642. //  Description:
  643. //        Construct the command that will apply the option box values.
  644. //
  645. //  Input Arguments:
  646. //      None.
  647. //
  648. proc string assembleCmd()
  649. {
  650.     string $cmd = "";
  651.  
  652.     setOptionVars(false);
  653.  
  654.     int $o = `optionVar -q displayPolyObjsAffected`;
  655.  
  656.     int $polyEdgeDisp[3]=`optionVar -q displayPolyEdgeDisp`;
  657.     float $polyBorderSize[3] =`optionVar -q displayPolyBorderEdgeSize`;
  658.     int $polyBorderHilite[3] =`optionVar -q displayPolyBorderEdgeHilite`;
  659.     int $polyVtxDisp[3]=`optionVar -q displayPolyVtxDisp`;
  660.     int $polyVtxNormalsDisp[3]=`optionVar -q displayPolyVertexNormals`;
  661.     int $polyFacetCntrDisp[3] = `optionVar -q displayPolyFacetCentreDisp`;
  662.     int $polyFacetNrmlDisp[3] = `optionVar -q displayPolyFacetNormalDisp`;
  663.     int $polyFacetTrnglDisp[3] = `optionVar -q displayPolyFacetTrngleDisp`;
  664.     int $polyFacetWarpDisp[3] = `optionVar -q displayPolyFacetWarpDisp`;
  665.     int $polyNumVertexDisp[3] = `optionVar -q displayPolyNumVertex`;
  666.     int $polyNumEdgeDisp[3] = `optionVar -q displayPolyNumEdge`;
  667.     int $polyNumFacetDisp[3] = `optionVar -q displayPolyNumFacet`;
  668.     int $polyNumUvDisp[3] = `optionVar -q displayPolyNumUv`;
  669.     float $polyNormalSize[3] = `optionVar -q displayPolyNormalSize`;
  670.     int $polyUVDisp[3] = `optionVar -q displayPolyUV`; 
  671.     int $polyUVTopologyDisp[3] = `optionVar -q displayPolyUVTopology`; 
  672.     int $polyBackFaceCull[3] = `optionVar -q displayPolyBackFaceCull`;
  673.     int $polyColorDisplay[3] = `optionVar -q colorShadedDisplay`;
  674.     int $polyColorChannel[3] = `optionVar -q colorMaterialChannel`;
  675.     int $polyVtxBackCull[3]    = `optionVar -q displayPolyVtxBackCull`;
  676.     int $bmh[3]=`optionVar -q displayPolyBorderMapHilite`;
  677.     
  678.     string $normalType="-facet";
  679.     int $dispNormals=0;
  680.     if ($polyVtxNormalsDisp[$o] != 0 || $polyFacetNrmlDisp[$o] != 0) {
  681.         $dispNormals=1;
  682.         if ($polyVtxNormalsDisp[$o] != 0) {
  683.             if ($polyFacetNrmlDisp[$o] != 0)
  684.             $normalType="-pointFacet";
  685.             else $normalType="-point";
  686.         } else $normalType="-facet";
  687.     }
  688.     string $affectType[] = {"-activeObjects", "-global", "-newPolymesh"};
  689.     string $edgeType[]    = {"-ae","-se","-he"};
  690.     string $backFaceCull[] = {"-bc","-fb","-wbc","-hb"};
  691.     string $facetHiliteType[] = {"full", "border", "center"};
  692.  
  693.     // Force uv display if uv topology display set on
  694.     // Force uv topology display off if uv display is off
  695.     if ($polyUVTopologyDisp[$o] != 0)
  696.     {
  697.         $polyUVDisp[$o] = true;
  698.     }
  699.     if ($polyUVDisp[$o] == 0)
  700.     {
  701.         $polyUVTopologyDisp[$o] = false;
  702.     }
  703.  
  704.     // Color strings to convert channel # to string. Must 
  705.     // be the same as for polyOptions command !
  706.     string $colorChannelStrings[] = {"none", "ambient", "ambientDiffuse",
  707.                 "diffuse", "specular", "emission"};
  708.  
  709.     $cmd = "polyOptions " + $affectType[$o] + " "
  710.     + $edgeType[$polyEdgeDisp[$o]] + " "
  711.     + " -sb " + $polyBorderSize[$o] + " "
  712.     + " -db " + $polyBorderHilite[$o] + " "
  713.     + " -dmb " + $bmh[$o] + " "        
  714.     + " -dv " + $polyVtxDisp[$o] + " "        
  715.     + " -dn " + $dispNormals + " " + $normalType + " "
  716.     + " -dc " + $polyFacetCntrDisp[$o]     + " "
  717.     + " -dt " + $polyFacetTrnglDisp[$o]     + " "
  718.     + " -dw " + $polyFacetWarpDisp[$o]     + " "
  719.     + " -din " + $polyNumVertexDisp[$o]     + " "+ $polyNumEdgeDisp[$o] + " "+ $polyNumFacetDisp[$o] + " "+ $polyNumUvDisp[$o]     + " "
  720.     + " -sn " + $polyNormalSize[$o]     + " "
  721.     + $backFaceCull[$polyBackFaceCull[$o]] + " "
  722.     + " -duv " + $polyUVDisp[$o] + " "
  723.     + " -uvt " + $polyUVTopologyDisp[$o] + " "
  724.     + " -cs " + $polyColorDisplay[$o] + " "
  725.     + " -cm " + $colorChannelStrings[$polyColorChannel[$o]] + " "
  726.     + " -bcv " + $polyVtxBackCull[$o] + ";";
  727.  
  728.     return $cmd;
  729. }
  730.  
  731. //
  732. //  Procedure Name:
  733. //      polysDisplaySetup
  734. //
  735. //  Description:
  736. //        Perform the optionBoxExample1 command using the corresponding 
  737. //        option values.  This procedure will also show the option box
  738. //        window if necessary as well as construct the command string
  739. //        that will invoke the optionBoxExample1 command with the current
  740. //        option box values.
  741. //
  742. //  Input Arguments:
  743. //      0 - Execute the command.
  744. //      1 - Show the option box dialog.
  745. //      2 - Return the command.
  746. //
  747. global proc string polysDisplaySetup(int $action)
  748. {
  749.     string $cmd = "";
  750.  
  751.     switch ($action) {
  752.  
  753.         //    Execute the command.
  754.         //
  755.         case 0:
  756.             //    Get the command.
  757.             //
  758.             $cmd = `assembleCmd`;
  759.  
  760.             //    Execute the command with the option settings.
  761.             //
  762.             eval($cmd);
  763.  
  764.             break;
  765.  
  766.         //    Show the option box.
  767.         //
  768.         case 1:
  769.             polysDisplaySetupOptions;
  770.             break;
  771.  
  772.         //    Return the command string.
  773.         //
  774.         case 2:
  775.             //    Get the command.
  776.             //
  777.             $cmd = `assembleCmd`;
  778.             break;
  779.     }
  780.     return $cmd;
  781. }
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.